#include "stdafx.h"

#include "LocatorPoseMex.h"

/// Konvertiert die Matlab-Matrix M in eine Armadillo-Matrix A. A muss als 1x1-Matrix angelegt sein.
/// @param	M	Matlab-Matrix
/// @param	A	Armadillo-Matrix
void convertMatlabToArma(const mxArray* M, arma::mat& A) {	
	if (A.n_elem != 1) mexErrMsgTxt("Matrix A must not have more than one element.");
	
	arma::access::rw(A.mem) = mxGetPr(M);
	arma::access::rw(A.n_rows) = mxGetM(M);
	arma::access::rw(A.n_cols) = mxGetN(M);
	arma::access::rw(A.n_elem) = A.n_rows * A.n_cols;
};

arma::mat convertMatlabToArma(const mxArray* M) {
	return arma::mat(mxGetPr(M), mxGetM(M), mxGetN(M), false, true);
}